using System;
using System.Collections.Generic;
using BasecampRestAPI;

namespace TestBasecampRestAPI.Fakes
{
	internal class FakeProject : IProject
	{
		#region Implementation of IProject

		public IBaseCamp Camp { get; set; }
		public int Id { get; set; }
		public string Name { get; set; }
		public DateTime CreatedOn { get; set; }
		public DateTime LastChangedOn { get; set; }
		public string Announcement { get; set; }
		public string Status { get; set; }
		public string StartPage { get; set; }
		public bool ShowWriteBoards { get; set; }
		public bool ShowAnnouncement { get; set; }
		public IPerson[] People
		{
			get { throw new System.NotImplementedException(); }
		}

		public IToDoList[] ToDoLists
		{
			get
			{
				ToDoListsGetCalled = true;
				return ToDoListsGetFakeResult;
			}
		}

		public IMilestone[] Milestones
		{
			get
			{
				throw new NotImplementedException();
			}
		}

		public IPost[] RecentMessages
		{
			get { throw new System.NotImplementedException(); }
		}

		public IPost[] ArchivedMessages
		{
			get { throw new System.NotImplementedException(); }
		}

		public IMilestone GetMilestoneById(int id)
		{
			GetMilestoneByIdCalled = true;
			GetMilestoneByIdLastId = id;
			return GetMilestoneByIdFakeResult;
		}

		public IMilestone CreateMilestone(string title, DateTime deadline, IPerson responsibleParty, bool notify)
		{
			CreateMilestoneCalled = true;
			CreateMilestoneLastTitle = title;
			CreateMilestoneLastDeadline = deadline;
			CreateMilestoneLastResponsibleParty = responsibleParty;
			CreateMilestoneLastNotify = notify;
			return CreateMilestoneFakeResult;
		}
		public bool CreateMilestoneCalled { get; private set; }
		public string CreateMilestoneLastTitle { get; private set; }
		public DateTime CreateMilestoneLastDeadline { get; private set; }
		public IPerson CreateMilestoneLastResponsibleParty { get; private set; }
		public bool CreateMilestoneLastNotify { get; private set; }
		public IMilestone CreateMilestoneFakeResult { private get; set; }

		public IToDoList CreateToDoList(string name, string description, IMilestone milestone, bool privateList, bool trackedList)
		{
			CreateToDoListCalled = true;
			CreateToDoListLastName = name;
			CreateToDoListLastDescription = description;
			CreateToDoListLastMilestone = milestone;
			CreateToDoListLastPrivateList = privateList;
			CreateToDoListLastTrackedList = trackedList;
			if (CreateToDoListFakeResults.ContainsKey(name))
			{
				return CreateToDoListFakeResults[name];
			}
			return CreateToDoListFakeResult;
		}

		public ICategory[] GetCategoriesForType(CategoryType type)
		{
			throw new System.NotImplementedException();
		}

		public ICategory CreateCategory(CategoryType type, string name)
		{
			throw new System.NotImplementedException();
		}

		public IPost[] GetMessagesForCategory(ICategory category)
		{
			throw new System.NotImplementedException();
		}

		public IPost[] GetArchivedMessagesForCategory(ICategory category)
		{
			throw new System.NotImplementedException();
		}

		public IPost CreateMessage(ICategory category,
			string title, string body, string extendedBody, bool isPrivate,
			IEnumerable<IPerson> notifications, IEnumerable<IAttachment> attachments)
		{
			throw new System.NotImplementedException();
		}

		public bool CreateToDoListCalled { get; private set; }
		public string CreateToDoListLastName { get; private set; }
		public string CreateToDoListLastDescription { get; private set; }
		public IMilestone CreateToDoListLastMilestone { get; private set; }
		public bool CreateToDoListLastPrivateList { get; private set; }
		public bool CreateToDoListLastTrackedList { get; private set; }
		public IToDoList CreateToDoListFakeResult { private get; set; }

		public bool GetMilestoneByIdCalled { get; private set; }
		public int GetMilestoneByIdLastId { get; private set; }
		public IMilestone GetMilestoneByIdFakeResult { private get; set; }

		public bool ToDoListsGetCalled { get; private set; }
		public IToDoList[] ToDoListsGetFakeResult { private get; set; }
		#endregion

		public void CreateToDoListFakeResultForName(string name, IToDoList list)
		{
			CreateToDoListFakeResults[name] = list;
		}
		private readonly Dictionary<string, IToDoList> CreateToDoListFakeResults = new Dictionary<string, IToDoList>();
	}
}